package com.ljfiction.book.Dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.widget.ImageView;
import android.widget.TextView;

import com.ljfiction.book.R;
import com.ljfiction.book.MyView.SuperButton;
import com.ljfiction.book.activitys.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Android on 2017/12/12.
 */

public class NoAuthorDialog {
    private Listener listener;
    private Context context;
    private Dialog mDialog;
    private  SuperButton isokToauthor;
    private TextView seekauthor;
    private ImageView deletnoauthor;

    public NoAuthorDialog(BaseActivity context, final Listener listener) {
        this.context = context;
        this.listener = listener;
        mDialog = new Dialog(context, R.style.AppTheme3);
        //填充对话框的布局
        View vi = LayoutInflater.from(context).inflate(R.layout.no_author_popuwindow, null);
        mDialog.setContentView(vi);
        mDialog.getWindow().setGravity(Gravity.BOTTOM);
        mDialog.getWindow().setWindowAnimations(R.style.ActionSheetDialogAnimation);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.show();
        isokToauthor= (SuperButton) vi.findViewById(R.id.isok_toauthor);
        seekauthor= (TextView) vi.findViewById(R.id.seekauthor);
        deletnoauthor= (ImageView) vi.findViewById(R.id.deletnoauthor);
        isokToauthor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener!=null){
                    listener.isokToauthor();
                }

            }
        });
        seekauthor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener!=null){
                    listener.seekauthor();
                }

            }
        });
        deletnoauthor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                close();
            }
        });
    }


    public Dialog show() {
        if (mDialog != null) {
            mDialog.show();
        }
        return mDialog;
    }

    public void close() {
        if (mDialog != null) {
            mDialog.dismiss();
        }
    }

    public static interface Listener {
        public void isokToauthor();
        public void seekauthor();
        public void deletnoauthor();
    }

}
